;;
;; File    : tests.scm
;; Version : 0.1
;; Author  : Harish Sharma
;; Date    : 11th May 2007
;;

(load "prelude.scm")
(load "engine.scm")

(define _test_board (l2v '(0 0 0 0 0 0 0 0 0 0    ;;  0-9
                           0 0 9 0 0 0 0 0 0 0    ;; 10-19
                           0 0 0 0 0 0 0 2 0 0    ;; 20-29
                           0 0 2 0 0 0 2 0 2 0    ;; 30-39
                           0 1 0 1 0 1 0 1 0 0    ;; 40-49
                           0 0 1 0 3 0 1 0 3 0    ;; 50-59
                           0 2 0 4 0 3 0 0 0 0    ;; 60-69
                           0 0 0 0 0 0 0 0 3 0    ;; 70-79
                           0 0 0 3 0 0 0 0 0 0    ;; 80-89
                           0 0 0 0 0 0 0 0 0 0))) ;; 90-99

;; 
(define (test-last)
  (if (not (= 4 (last '(1 2 3 4)))) (printf "\nlast failed (1 2 3 4)"))
  (if (not (= 1 (last '(1)))) (printf "\nlast failed (1)"))
  (if (not (null? (last '()))) (printf "\nlast failed ()")))


;; test cases for testing function valid-move?
(define (test-valid-move?)
  ;; test all possible valid black moves
  (if (not (valid-move? '(61 52))) (printf "\n~a failed" '(61 52)))
  (if (not (valid-move? '(63 52))) (printf "\n~a failed" '(63 52)))
  (if (not (valid-move? '(63 54))) (printf "\n~a failed" '(63 54)))
  (if (not (valid-move? '(65 54))) (printf "\n~a failed" '(65 54)))
  (if (not (valid-move? '(65 56))) (printf "\n~a failed" '(65 56)))
  (if (not (valid-move? '(67 56))) (printf "\n~a failed" '(67 56)))
  (if (not (valid-move? '(67 58))) (printf "\n~a failed" '(67 58)))
  
  (if (not (valid-move? '(72 54))) (printf "\n~a failed" '(72 54)))
  (if (not (valid-move? '(74 52))) (printf "\n~a failed" '(74 52)))
  (if (not (valid-move? '(74 56))) (printf "\n~a failed" '(74 56)))
  (if (not (valid-move? '(76 54))) (printf "\n~a failed" '(76 54)))
  (if (not (valid-move? '(76 58))) (printf "\n~a failed" '(76 58)))
  (if (not (valid-move? '(78 56))) (printf "\n~a failed" '(72 54)))

  ;; test all possible valid red moves
  (swap-turns)
  (if (not (valid-move? '(32 41))) (printf "\n~a failed" '(32 41)))
  (if (not (valid-move? '(32 43))) (printf "\n~a failed" '(32 43)))
  (if (not (valid-move? '(34 43))) (printf "\n~a failed" '(34 43)))
  (if (not (valid-move? '(34 45))) (printf "\n~a failed" '(34 45)))
  (if (not (valid-move? '(36 45))) (printf "\n~a failed" '(36 45)))
  (if (not (valid-move? '(36 47))) (printf "\n~a failed" '(36 47)))
  (if (not (valid-move? '(38 47))) (printf "\n~a failed" '(38 47)))
  
  (if (not (valid-move? '(21 43))) (printf "\n~a failed" '(21 43)))
  (if (not (valid-move? '(23 41))) (printf "\n~a failed" '(23 41)))
  (if (not (valid-move? '(23 45))) (printf "\n~a failed" '(23 45)))
  (if (not (valid-move? '(25 43))) (printf "\n~a failed" '(25 43)))
  (if (not (valid-move? '(25 47))) (printf "\n~a failed" '(25 47)))
  (if (not (valid-move? '(27 45))) (printf "\n~a failed" '(27 45)))
  (swap-turns))

(test-last)
(test-valid-move?)
